<?php
/**
 * 消息消息接口
 * 获取系统消息，包含点赞消息和系统消息
 * 验证用户身份token
 * @author Edwin
 */

namespace V1\Controller;

use Common\Controller\ApiController;

class MessageController extends ApiController
{
    public function rest()
    {
        switch ($this->_method) {
            case 'get': // get请求处理代码
                $this->_get();
                break;
        }
    }

    /**
     * 获取输出对应消息
     */
    private function _get()
    {
        $info['opt'] = I('get.opt');
        $info['userid'] = $this->userId;
        $message = D('Message');
        switch (I('get.action')) {
            //获取推送消息列表
            case 'get_msg':
                $list = $message->get_messList($info);
                $show['msg_list'] = !empty($list) ? $list : [];
                break;
            //判断消息是否已读
            case 'is_read':
                $show['status'] = $message->get_mess_status($info);
                break;
            default:
                $show['status'] = 201;
                break;
        }
        $this->myApiPrint('success', 200, $show);
    }

}